package Demo_0401.lianxi;

import Demo_0401.SqListClass;

/**
 * @author:zhengyilong
 * @email:1797344574@qq.com
 * @phone:13479394730
 * @desc:
 * @DateTime:2022/4/8 9:39
 **/
public class Demo1 {
    public static void main(String[] args) {
        //最大值最小值交换{1,2,3,4,5,}-->{5,2,3,4,1}
        Integer [] arr = {1,2,3,4,5};

        int min = arr[0];
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (arr[i]<min){
                min=arr[i];
            }
            if(arr[i]>max){
                max=arr[i];
            }
        }

        SqListClass<Integer> list = new SqListClass<>();
        list.CreateList(arr);
        int minI = list.GetNo(min);
        int maxI = list.GetNo(max);
        list.swap(minI,maxI);
        System.out.println(list);
    }
}

